package com.taptech.doufu.ui.adapter.personalcenter;

import android.content.Context;
import android.graphics.Color;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.ImageView;
import android.widget.TextView;

import com.taptech.doufu.R;


public class CollectPopAdapter extends BaseAdapter
{
    private Context mContext;
    public static final int TYPE_COLLECT = 1;
    public static final int TYPE_DRAT = 2;
    public static final int TYPE_TAG_CONTENT = 3 ;
    private String tagContentType[] = {"全部" , "小说" , "文评" , "帖子","插画"};
    public String collect[] = {"全部收藏" , "小说收藏" ,"漫画收藏", "文评收藏" };
    public String draft[] = {"全部草稿", "帖子草稿"};
    public int selectPosition = 0;

    public CollectPopAdapter(Context mContext, int type)
    {
        // TODO Auto-generated constructor stub
        this.mContext = mContext;
        if (type == TYPE_DRAT)
        {
            collect = draft;
        }else if (type == TYPE_TAG_CONTENT){
            collect = tagContentType;
        }
    }


    @Override
    public int getCount()
    {
        // TODO Auto-generated method stub
        return collect.length;
    }

    @Override
    public Object getItem(int position)
    {
        // TODO Auto-generated method stub
        return position;
    }

    @Override
    public long getItemId(int position)
    {
        // TODO Auto-generated method stub
        return position;
    }

    public void setSelectPosition(int selectPosition)
    {
        this.selectPosition = selectPosition;
    }

    public String getCollentTitle(int position)
    {
        return collect[position];
    }

    @Override
    public View getView(int position, View convertView, ViewGroup parent)
    {
        // TODO Auto-generated method stub
        ViewHolder viewHodler;
        if (convertView == null)
        {
            viewHodler = new ViewHolder();
            convertView = LayoutInflater.from(mContext).inflate(R.layout.novel_des_pop_list_item, null);
            viewHodler.curPage = (TextView) convertView.findViewById(R.id.novel_des_pop_list_item_tv);
            viewHodler.selectImag = (ImageView) convertView.findViewById(R.id.novel_des_pop_list_item_sel_img);
            convertView.setTag(viewHodler);
        } else
        {
            viewHodler = (ViewHolder) convertView.getTag();
        }

        viewHodler.curPage.setText(collect[position]);
        if (position == selectPosition)
        {
            viewHodler.curPage.setTextColor(Color.parseColor("#ff6e70"));
            viewHodler.selectImag.setVisibility(View.VISIBLE);
        } else
        {
            viewHodler.curPage.setTextColor(Color.parseColor("#666666"));
            viewHodler.selectImag.setVisibility(View.GONE);
        }

        return convertView;
    }

    public String getTagContentType(int position) {
        return tagContentType[position];
    }

    class ViewHolder
    {
        TextView curPage;
        ImageView selectImag;
    }
}
